Skip to content

fix: resolve HOT_STREAK badge flickering by excluding today's incomplete data#347

Open
Yashaswini-K-P wants to merge 3 commits into
codepvg:mainfrom
Yashaswini-K-P:fix/hot-streak-calculation
Open

fix: resolve HOT_STREAK badge flickering by excluding today's incomplete data#347
Yashaswini-K-P wants to merge 3 commits into
codepvg:mainfrom
Yashaswini-K-P:fix/hot-streak-calculation

Conversation

@Yashaswini-K-P

Copy link
Copy Markdown
Contributor

Description

This PR fixes an issue where the HOT_STREAK badge would prematurely disappear or flicker on the current calendar day. Previously, the streak calculation included today's incomplete data in its evaluation, causing the badge to be withheld until a problem was solved. By adjusting the history slice to look at the last 8 days excluding the current incomplete day, the badge now remains correctly visible throughout the day for users with an active streak.

Linked Issue

Fixes #269

Changes Made

  • Modified loadBadges function logic.
  • Updated the history slice window from (-8) to (-9, -1) to exclude today's incomplete data from the HOT_STREAK calculation.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally (using real user history and verified badge persistence)
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

N/A

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed one issue with the current approach.

By using history.slice(-9, -1), today's snapshot is excluded entirely. This means that if a user completes their 7th consecutive day today, today's progress won't be considered and the badge won't be awarded until tomorrow's snapshot is generated.

I'd prefer an approach that still includes today's snapshot while ensuring an incomplete current day doesn't incorrectly break an existing streak. That handles both edge cases correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: HOT_STREAK badge is withheld/dropped due to incomplete data tracking for the current day

2 participants